<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="请求员工数据">
<table border="1">
    <caption>员工列表</caption>
    <tr>
        <th>姓名</th>
        <th>工资</th>
        <th>工作</th>
    </tr>
</table>
<!--引入一个jQuery框架-->
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
    //JavaScript中的对象
    let obj1 = {}; //空对象
    let obj2 = {name:"tom" , age:18};
    let obj3 = {
        name:"刘德华",
        run:function () {
            alert("我叫"+this.name)
        }
    }  //带有属性的方法和对象
    obj3.run(); //调用对象里面的方法
    let emp = {name:"刘备",salary:5000,job:"销售"};  //表示一个员工对象
    //给按钮添加点击事件
    $("input").click(function () {
        let arr = [
            {name:"刘备",salary:5000,job:"销售"},
            {name:"关羽",salary:5000,job:"销售"},
            {name:"张飞",salary:5000,job:"销售"}
        ];//表示一个数组里面装了多个员工对象
        //遍历数组中的员工对象
        for (let e of arr) {
            let tr = $("<tr></tr>");
            let nameTd = $("<td></td>");
            nameTd.text(e.name);
            let salTd = $("<td></td>");
            salTd.text(e.salary);
            let jobTd = $("<td></td>");
            jobTd.text(e.job);
            tr.append(nameTd);
            tr.append(salTd);
            tr.append(jobTd); //把td装进tr
            $("table").append(tr); //把tr装进table
        }

    })
</script>
</body>
</html>